package com.example.panda;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.panda.adapter.StartTeamListAdapter;
import com.example.panda.Item.StartTeamListItem;

import java.util.ArrayList;
import java.util.List;

public class StartTeamListViewActivity extends Activity {
    ListView listView;
    Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.start_team_list_activity);
        button = (Button) this.findViewById(R.id.list_btn);
        View view;
        List<StartTeamListItem> data = new ArrayList<StartTeamListItem>();
        for(int i = 0; i < 1; i++) {
            data.add(new StartTeamListItem(R.string.destination, R.string.destination1, R.drawable.mudi));
            data.add(new StartTeamListItem(R.string.description, R.string.description1, R.drawable.miaoshu));
            data.add(new StartTeamListItem(R.string.budget, R.string.budget1, R.drawable.yusuan));
            data.add(new StartTeamListItem(R.string.date, R.string.date1, R.drawable.riqi));
            data.add(new StartTeamListItem(R.string.people, R.string.people1, R.drawable.renshu));
            data.add(new StartTeamListItem(R.string.relation, R.string.relation1, R.drawable.lianxi));
        }
        listView = findViewById(R.id.list_view);
        StartTeamListAdapter adapter =new StartTeamListAdapter(this,R.layout.start_team_list_item, data);
        listView.setAdapter(adapter);

        //为按钮设置单击监听，并在onClick中实现
        final View view1 = LayoutInflater.from(this).inflate(R.layout.start_team_list_item,null);
        Button button = (Button)this.findViewById(R.id.list_btn);
        final EditText editText = (EditText) view1.findViewById(R.id.tv_list02);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (TextUtils.isEmpty(editText.getText().toString())){
                    Toast.makeText(StartTeamListViewActivity.this,"您的组队信息有误",Toast.LENGTH_LONG).show();
                }else {
                    Intent intent = new Intent(StartTeamListViewActivity.this, JoinTeamGridViewActivity.class);
                    startActivity(intent);
                }
            }
        });
    }
}
